document.querySelectorAll('.buttons button').forEach(function(button) {
    button.addEventListener('click', function() {
        var calculatorInput = document.getElementById('calculatorInput');
        var current = calculatorInput.value;
        var value = this.value;

        if (value === 'C') {
            calculatorInput.value = '';
        } else if (value === '=') {
            try {
                calculatorInput.value = eval(current);
            } catch (error) {
                calculatorInput.value = '错误';
            }
        } else {
            calculatorInput.value = current + value;
        }
    });
});
function clearEntry() {
    var inputElement = document.getElementById('calculatorInput');
    var inputValue = inputElement.value;
    if (inputValue.length > 0) {
        inputElement.value = inputValue.slice(0, -1);
    }
}
function calculatorInput() {
    var inputElement1 = document.getElementById('calculatorInput');
    var inputValue1 = inputElement1.value;
    if (inputValue1.trim() === 'e') {
        return Math.E;
    }
    const parts = inputValue1.trim().split('%');
    if (parts.length === 2) {
        const num1 = parseFloat(parts[0].trim());
        const num2 = parseFloat(parts[1].trim());
        if (!isNaN(num1) && !isNaN(num2)) {
            return num1 % num2;
        }
    }

    return 'Invalid input';
}
console.log(calculate('e'));
console.log(calculate('10%3'));
console.log(calculate('invalid input'));